package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.dto.ProductDetailDto;
import com.cskaoyan.shopping.dto.AllProductResponse;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.form.PageRequest;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

/**
 * GoodsController
 *
 * @description:
 * @author chen
 * @date 2022/8/25
 * @Time 10:01
 */
@RestController
public class GoodsController {
    @Autowired
    IProductService iProductService;
    @RequestMapping("/shopping/product/{id}")
    public ResponseData product(@PathVariable("id") Long id) {
        ProductDetailDto productDetail = iProductService.getProductDetail(id);
        return new ResponseUtil<ProductDetailDto>().setData(productDetail,"success");
    }

    @RequestMapping("/shopping/goods")
    public ResponseData goods(PageRequest pageRequest) {
        AllProductResponse allProduct = iProductService.getAllProduct(pageRequest);
        return new ResponseUtil<AllProductResponse>().setData(allProduct,"success");
    }

    @RequestMapping("/shopping/recommend")
    public ResponseData recommend() {
        Set<PanelDto> recommendGoods = iProductService.getRecommendGoods();
        return new ResponseUtil<Set>().setData(recommendGoods,"success");
    }

}
